package com.training.admin.dao;

import java.util.List;

import com.demo2do.core.persistence.annotation.Dao;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;
import com.training.admin.entity.project.CourseTraineeStat;
import com.training.admin.entity.project.ProjectPhaseCourse;
import com.training.admin.entity.project.ProjectTrainee;
import com.training.admin.entity.trainee.Trainee;

/**
 * @author xiaoHU
 *
 */
@Dao("hibernate")
public interface CourseTraineeStatDao {

    /**
     * @param projectPhaseCourse
     * @param projectTrainee
     * @return
     */
    @Query("FROM CourseTraineeStat WHERE disabled = false AND projectPhaseCourse = :projectPhaseCourse AND projectTrainee = :projectTrainee")
    public CourseTraineeStat loadByCourseAndTrainee(@Variable("projectPhaseCourse") ProjectPhaseCourse projectPhaseCourse, @Variable("projectTrainee") ProjectTrainee projectTrainee);
    
    /**
     * 
     * @param traineeIds
     * @return
     */
    @Query("FROM CourseTraineeStat WHERE disabled = false AND trainee.id in (:trainees)")
    public List<CourseTraineeStat> list(@Variable("trainees") List<Long> traineeIds);

    /**
     * @param trainees
     * @param courseIds
     * @return
     */
    @Query("FROM CourseTraineeStat WHERE disabled = false AND trainee in (:trainees) AND course.id in (:courseIds)")
    public List<CourseTraineeStat> listByTraineesAndCourseIds(@Variable("trainees") List<Trainee> trainees, @Variable("courseIds") List<Long> courseIds);

}
